<?php 
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
//@todo: load by domain -> website
$templatepath = "template/trassenheide/"; 

$nav_key = 1;
$subnav_key = 1;
$url = "trassenheide";

unset( $navigation[0]['type'] );
unset( $navigation[0]['type_id'] );
unset( $navigation[0]['depth'] );
unset( $navigation[0]['title'] );
unset( $navigation[0]['url'] );
unset( $navigation[0]['id'] );

//@todo: make a better calculation if a deeper structure is given
foreach( $navigation[0] as $key => $value ){
	if( $value['url'] == $menu_url ){
		$nav_key = $key;
		$url = $value['url'];
	} else {
		if( is_array( $value ) ){
			foreach( $value as $k => $v ){
				if( !empty( $v['title'] ) && $v['url'] == $menu_url ){
					$nav_key = $key;
					$subnav_key = $k;
					$url = $value['url'];
				}
			}
		}
	}
}

unset( $navigation[0][$nav_key]['type'] );
unset( $navigation[0][$nav_key]['type_id'] );
unset( $navigation[0][$nav_key]['depth'] );
unset( $navigation[0][$nav_key]['title'] );
unset( $navigation[0][$nav_key]['url'] );
unset( $navigation[0][$nav_key]['id'] );

$count = 0;
$keys = array_keys( $navigation[0][$nav_key] );
if( !empty( $navigation[0][$nav_key] ) ){
?>
<div id="submenu" class="color-box nopad">
	<div>
		<h3 class="h3-<?php echo $url; ?>">Ostseebad Trassenheide</h3>
		<div>
			<ul class="menu">
				<?php foreach( $navigation[0][$nav_key] as $key => $value ){ 
					$current = '';
					if( $subnav_key == $key ){
						$current = ' class="open current"';
					}
					?>
					<li<?php echo $current;?>><a id="left-item<?php echo $count + 1; ?>" href="<?php echo site_url( ); ?>/welcome/page/<?php echo $value['url']?>"><?php echo $value['title']?></a>
				    	<?php
				    	unset( $value['type'] );
						unset( $value['type_id'] );
						unset( $value['depth'] );
						unset( $value['title'] ); 
						unset( $value['url'] );
						unset( $value['id'] );
						if( count( $navigation[0][$nav_key][$keys[$count]] ) != 5 && $subnav_key == $key ) { 
							?>
							<ul>
							<?php
							unset( $navigation[0][$nav_key][$key]['type'] );
							unset( $navigation[0][$nav_key][$key]['type_id'] );
							unset( $navigation[0][$nav_key][$key]['depth'] );
							unset( $navigation[0][$nav_key][$key]['title'] ); 
							unset( $navigation[0][$nav_key][$key]['url'] ); 
							unset( $navigation[0][$nav_key][$key]['id'] ); 
							foreach( $navigation[0][$nav_key][$key] as $k => $v ){ 
								?>
					        	<li><a href="<?php echo site_url( ); ?>/welcome/page/<?php echo $v['url']?>"><?php echo $v['title']; ?></a></li>
						        <?php 
							} //foreach ?>
							</ul>
						<?php } //if ?>
					</li>
					<?php 
					$count++;
				} //foreach ?>
			</ul>
		</div>
	</div>
</div>
<?php } ?>